package com.wanxi.Internet.group;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.nio.charset.StandardCharsets;

public class Send {
    public static void main(String[] args) {
        DatagramSocket datagramSocket = null;
        try {
            System.out.println("发送端启动");
            datagramSocket = new DatagramSocket();

            byte [] bytes= "你在哪儿？王海云".getBytes(StandardCharsets.UTF_8);

            InetAddress inetAddress = InetAddress.getByName("224.0.2.0");

            DatagramPacket datagramPacket = new DatagramPacket(bytes,0,bytes.length,inetAddress,1948);

            datagramSocket.send(datagramPacket);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if(datagramSocket!= null)
            datagramSocket.close();
        }

    }
}
